Top 10k strings from Interactive BASIC Programming (1985)(Eigen Software)(Tape 1 of 3 Side B).tzx in <root> / bin / z80 / software / Sinclair Spectrum Collection TOSEC.exe / Sinclair ZX Spectrum - Utilities & Educational / Sinclair ZX Spectrum - Utilities & Educational - [TZX] (TOSEC-v2007-01-01) /

Back to the directory listing

   6 ;"Press any key to continue":
   3  statements.
   3  statement.
   3  Run the program found in   this Learning Element.
   3  Run the program found in   this Learning Element
   2 yourname=632.1
   2 circumference=2
   2 RANDOMIZE USR 
   2 ;"toggle sound:      SPACE & ENTER"
   2 ;"help:         CAPS SHIFT & ENTER";
   2 ;"has a circumference of ";circumference;
   2 ;"forward:    SYMBOL SHIFT & SPACE";
   2 ;"backward:   SYMBOL SHIFT & ENTER";
   2 ;"and an area of ";area
   2 ;"WARNING: if you enter 
   2 ;"Loading, please wait!"
   2 ;"Interactive BASIC Programming";
   2 ;"Copyright 
   2 ;"A circle of radius ";radius;
   2 80,75  then                
   2 ,       it must be followed by            
   2 "Please enter radius ";radius
   2  the Solution, then 
   2  1985 Eigen Software"
   2      EIGEN SOFTWARE";
   2           create reality"
   1 x, y, s and t
   1 x (where x
   1 total=total+anumber
   1 statement                                
   1 refer to the same box, as far asyour Spectrum is concerned.
   1 r. The areaof a circle equals 
   1 r,c;x;",";y
   1 prints 36.     Both 
   1 module d  
   1 module c  
   1 just  to  see what happens!
   1 it could easily have been:        
   1 give an arc on the other side ofthe imaginary line. Run the     program found in this Learning  Element.
   1 facilities encounter-ed so far.
   1 ensure circle       is not "rubbed out"
   1 d$="Tuesday"
   1 d$;" ";day;" ";m$;" ";year
   1 count=count+1
   1 c=d*c                   130 
   1 c=6                     110 
   1 are not allowed.                                        
   1 a=(4+8)^(9-7)           
   1 You might want to look          at this program when            you've learnt more              about Basic.                                           
   1 What you might not have realisedthough is that each character   square is made up of 8 rows and 8 columns of dots!  Computer    people call these dots pixels   (picture elements). Hence each  character square contains       8*8 = 64 pixels.
   1 Try one line per bar
   1 This is a bit long     winded. We can place several    statements on one line if we    separate each one with a colon :
   1 Silly menu driven               program
   1 Set up axes
   1 Print the name of a             town
   1 Print square root
   1 Plot a cross
   1 Play a tune
   1 More circle data
   1 Make the border red
   1 MODULE D  &?
   1 MODULE C  
   1 LeonardCohen
   1 If you have any        suggestions for 'Advanced       Interactive BASIC Programming'  then Eigen Software would be    grateful to hear them. Thankyou
   1 Green Sleeves
   1 GOTO 220           
   1 Draw a circle
   1 Don't worry about this          program, just run it.                   
   1 Don't worry about this          program, just run it.    
   1 Don't worry about this          program, just run it!                               
   1 Date again
   1 Created with Ramsoft MakeTZX
   1 Circle data
   1 ;option;" not available!":
   1 ;count;" numbers so far.";
   1 ;....     then 
   1 ;"y-coordinate no good, try again!":
   1 ;"x-coordinate no good, try again!":
   1 ;"x first";
   1 ;"entering  1, 2, 3 or 4"
   1 ;"The square root of ";number;
   1 ;"The date is ";Day;"/";Month;"/";Year
   1 ;"The circle is too big to draw!"
   1 ;"That's too hard, try again:":
   1 ;"Straight lines to begin with.                                   
   1 ;"Select option by";
   1 ;"Running total is ";total
   1 ;"Press any key to end"
   1 ;"Portree"
   1 ;"Now for a curve.                                                
   1 ;"Learning Module D"
   1 ;"Learning Module C"
   1 ;"4  Make the border red"
   1 ;"3  Draw a circle";
   1 ;"255,90";
   1 ;"2  Play a tune";
   1 ;"166,93";
   1 ;"166,137"
   1 ;"140,120"
   1 ;"1  Print the name of a town";
   1 ;", then y"
   1 ;"       ";
   1 ;"                                "
   1 55,0  gives a horizontal   line because there is no change in the y-coordinate.                                                    ";
   1 54,0   gives a horizontal              line to the right.";
   1 40,30  draws a line from   100,90 to 100+40,90+30 (i.e. to 140,120)"
   1 255,90  then               
   1 25,20  then  
   1 166,93  then               
   1 125,85                 120 
   1 120,16          
   1 110,20  gives";
   1 100,90  gives:"
   1 0,44    gives a vertical                line upwards.";
   1 0,-78   gives a vertical                line downwards.";
   1 0,-66  gives a vertical    line because there is no change in the x-coordinate. "
   1 /6      radians. 
   1 .02,33                 150 
   1 . What would  you expect 
   1 . Thenwrite a program that inputs     three numbers for today's date  and prints it in the form 5/6/59
   1 . Temporary colour items can be used too.
   1 . So you now have a way for repeating BASIC.                                            Use 
   1 . Negative values of 
   1 . If y then clear the screen (using
   1 . If the condition  is true then the instructions   are carried out. If the         condition is false then the     Spectrum ignores the            instructions and goes on to the next line.                      Let's see what is meant by a    condition. First take a look at the following relations:          
   1 . Forsmaller arcs 
   1 .  The  modified 
   1 .   Then it draws a straight line   from the old plot position to   the new plot position i.e. from 
   1 .                                      The string that does not containany characters at all ("") is   called the empty string.        (N.B. " " is  not the empty      string since it contains the    character whose code is 32.)
   1 .                                                     Please note that 
   1 .                                                     Experiment for a while with
   1 .         
   1 -33,0  gives a horizontal              line to the left.";
   1 , multiply it by itself
   1 , centred at  
   1 ,  hence a semi-circle is 
   1 ,   add one to it and replace it in the same box. 
   1 ,        i.e. all 
   1 ,                         
   1 ,                       
   1 ,                    
   1 ) for the name of a      string variable e.g. 
   1 ) for each circle.
   1 ) at  the end of the name of a string variable.
   1 ) a string.   The following are examples of   strings: 
   1 (i.e. 768    character positions).           
   1 (You will have to press CAPS SHIFT and  BREAK {just BREAK} tostop the program.)
   1 "y-coordinate please? (0-175) ";y
   1 "x-coordinate please? (0-255) ";x
   1 "c=";c;"d=";d;"e=";e
   1 "Year?  ";year
   1 "Please give me a number"
   1 "Month? ";m$
   1 "First we'll use a 
   1 "First plot a pixel, this gives  us a sensible point to start.                                   
   1 "Enter a number please ";number
   1 "Day of the week? ";d$
   1 "Day of the month? ";day
   1 "August 1914"
   1 "Arcs from larger circles";
   1 "Another pixel? (y/n) ";a$
   1 "Another number? (y/n) ";a$
   1 "All manner of curves!"
   1 "Ahhh. That's better....."
   1  would print    144 since 4+8=12 and 9-7=2      so  (4+8)^(9-7) is the same as  12^2 = 144.                     Write a program that asks for   a radius and prints the         circumference and area of the   corresponding circle. (Spectrum contains
   1  will print 8Try it.
   1  will print 
   1  will draw a    circle of radius 
   1  variablename 
   1  variable=
   1  to the ink colour. You can also use the temporary  colour items 
   1  to draw a smile (with teeth!).
   1  to do? Try it.
   1  to calculatea new plot position, say 
   1  the start).
   1  the begining of the program.    (In fact the first line of your program could be 
   1  tells the   Spectrum to add
   1  tells the       computer to cease execution of  the program.)                   Write a short program that uses a simple menu like:                1  Print the name of a town     2  Play a tune                  3  Draw a circle                4  Make the border red
   1  statementse.g.  
   1  statements. Write a programthat draws a multi-coloured kiteor a plant or a dinosaur or a   tin of custard powder!
   1  statements.                                                     Try   
   1  statements,each one following a suitable   
   1  statements to make up  your own zaps.
   1  statements after the 
   1  statements   but are printed on the input    line! Enter 
   1  statements                      e.g.     
   1  statement:                   
   1  statement. Write a program that plots a small crossin the centre of the screen.
   1  statement. Print a      message if the circle is too    big.
   1  statement tells your     Spectrum to stop executing the  current sequence of instructionsand continue from the specified line of the program. 
   1  statement may be   useful.
   1  statement lets us place lines and curves on    the screen and 
   1  statement it produces aflashing cursor and expects you to type  in a number.           Run this program:                        
   1  statement is used  to place dots on the screen, i.eit changes a pixel to the ink   colour. The 
   1  statement in a way similar to the 
   1  statement for repetition.
   1  statement for  repetition.
   1  statement draws anarc (not a circle) from 
   1  statement  to give the answer, e.g.        
   1  statement  and uses this position as a     starting point for the 
   1  so on      receiving y you would just      have to 
   1  set the plot position to 0,0
   1  semitones above      (below if 
   1  semi-circle. Exampleswill make this clear (continue).
   1  seconds at apitch of 
   1  radius<=87
   1  radius                    
   1  radiansand 30
   1  radians correspond to 360
   1  program continues below                               
   1  now exists  inyour Spectrum and it contains   the number you entered. To provethis, enter 
   1  mybankbalance=30000000
   1  moves the    pitch up or down by octaves.    Try entering 
   1  means raise to the powerof. So 
   1  means jump (or go to) line 
   1  means is not equal to.                                   So the following conditions are true: 
   1  means  find the square root of what    follows. So 
   1  means   take what is present in variable
   1  lie inside the range 0-255  and 
   1  lie inside the     range 0-175.
   1  less than                    
   1  is used   for circles - easy isn't it!
   1  is the vertical coordin-  ate (0-175)] will change the    pixel at 
   1  is the same as 
   1  is the same as
   1  is the  horizontal coordinate (0-255)   and 
   1  is negative) middle C. (Refer to the first diagram  in Chapter 19 of your Spectrum  Handbook {HOW TO MAKE MUSIC AND SOUND EFFECTS in Chapter 2}).   One octave is represented as:                                     C C# D E
   1  is another   way of giving (assigning) a     number to a variable. When your Spectrum executes (carries out) an 
   1  is a full    circle. The Spectrum uses anoth-er measure of angle: radians.   2
   1  is a    positive or negative number)  isused to put the number x into a box called
   1  is a        modification of 
   1  is  measured in radians. 
   1  into it.                                              Now write a program that inputs appropriate information and     prints the current date in the  form:                                  Saturday 8 September 1984
   1  have higher     precedence than 
   1  give anarc on the right hand side of   the imaginary straight line from
   1  from the last 
   1  draws asemi-circle from 
   1  draws a  semicircle on the opposite side to the 
   1  d=c+7                   120 
   1  corresponds to a right angle whereas 360
   1  circumference=2*
   1  causes      Spectrum's loudspeaker          (quietspeaker!) to make a sound for a duration of 
   1  can take any values(positive or negative) as long  as the resulting 
   1  can range from -60 to 69.  Write a program that plays a    simple tune of your choice.
   1  because the square     root of 25 is 5 and 5*6=30. You can use brackets to evaluate    something more complicated.     So 
   1  as before)   through an angle 
   1  are legal variableswhereas 
   1  are carried  out before 
   1  and    place the answer back in the    variable 
   1  a number"
   1  You will need to write     something like 
   1  You will need to use an    
   1  You will need to input two strings and two numbers.
   1  You will need four 
   1  You can place several       statements on one BASIC line.   This is done by placing a colon (:) between each statement.     e.g.  
   1  You can have statements like
   1  You can draw successive    lines or arcs with several 
   1  Write a program that draws  x- and y- axes for a graph and  label them accordingly.
   1  Write a program that draws  several concentric circles.
   1  Write a program that draws  a picture of your own design.
   1  Write a program that acceptsa number as input and prints itssquare root with a suitable     message.
   1  Write a program that       combines 
   1  Work out the total number   of pixels (dots) on the Spectrumscreen.
   1  Why not try writing a       program that prints the         perimeter and area of a         rectangle and then draws the    rectangle, given its length and breadth?
   1  When you've learnt more     BASIC. We'll show you how to    write a program  for sketching  colour pictures.                Meanwhile, write a program that uses all the 
   1  We'll have a listen to some sound now. 
   1  We will now look at an      extremely important part of     BASIC: 
   1  We cannot use all of the    49152 pixels because the bottom two rows are reserved for input.We can draw, however, on a grid that is 176 pixels high (22 rowseach 8 pixels high) and 256     pixels wide (32*8).
   1  Wait a minute! Let's look atyour last program (the one that draws circles). If you were to  enter a radius greater than 87  the circle would go off the     screen and your Spectrum would  produce the "out of screen"     error message.                  If you place the centre of the  circle in the middle of the     screen (127,87) the largest     circle you can draw has a       radius of 87. Enter a larger    radius in your program, just    to see what happens!
   1  Use three different        variables.
   1  Use three 
   1  Use the same centre (i.e   the same values of 
   1  Use something like 
   1  Use several 
   1  Use four separate 
   1  Use different values of
   1  Try plotting these         coordinates:                    
   1  This is an example of an
   1  This Learning Module is all about drawing lines, curves and circles. Also some sound.       The Spectrum screen is made up  of 24 rows and 32 columns. So   there are 24*32=768 squares intowhich you can put a letter,     digit, symbol etc. 
   1  There is one restriction:   you can only use a single letter(plus 
   1  Then experiment with 
   1  Then enter a number. The    variable 
   1  The pitch values for a      
   1  The names given to variablescan be of any length but can    only be made up of letters and  digits and they must start with a letter (phew!). 
   1  The circumference of a     circle is equal to 2
   1  The Spectrum remembers 
   1  The Spectrum expects us to  refer to each pixel using a     coordinate system. Don't worry, coordinates are really quite    easy to understand. Honestly!   Look at the screen layout given in Chapter 15 of the Spectrum   Manual {last page}.             x-coordinates start at the      bottom left corner of the       screen with the value 0 and     increase from left to right up  to the value 255. In a similar  way the y-coordinates start at 0in the bottom left corner of thescreen (ignoring rows 22 and 23)and increase from bottom to top up to the value 175.
   1  Text (and colour items) can be placed in 
   1  THEN CIRCLE
   1  String variables are boxes  that are quite different from   numerical  variables and you    must tell your Spectrum which   you are using! This is done by  placing a dollar symbol (
   1  So far we have used specificnumbers and text. However, your Spectrum really comes into its  own when we use numbers and textthat change. Such changeable    things are called variables. We will deal with numeric variablesfirst.                          Think of a numeric variable as abox set aside in the Specrtum's memory. This box can contain    only numbers. Because we might  want to use several "boxes" at  once we need to refer to them   separately. So, each box is     given a name by the programmer. In fact the very act of using   the name creates the variable   (or box). However, do not try toget a number out of a box if youhave not already put one in!
   1  Run the program found in    this Learning Element.
   1  Remember to use short     durations.
   1  Remember that after a 
   1  Positive values of
   1  Notice line 180 of the lastprogram. It contained  
   1  Modify your program so that it draws a circle with the      correct radius as well as       printing the circumference and  area.
   1  Modify your program so it   puts up the prompt:  Another    number? (y/n). If the response  is n then 
   1  Like numeric variables,     string variables are created by using them! 
   1  Let's have a look at two of the functions available on your Spectrum: 
   1  Let's consider angular      measure. We are used to         measuring angles in degrees so  that 90
   1  In order to produce zaps   and the like you will need to   experiment with small durations.Try:    
   1  In order to make the programfool-proof you will need to     check to see whether the radius is greater than 87. If so then  don't bother to draw the circle.Or you could test for the radiusbeing less than or equal to 87  and if so, draw the circle.     Note the meaning of the         following relations that are    produced by pressing symbol     shift and keys on the second row  
   1  If you know how to read     sheet music then try converting printed notes to 
   1  If you havn't looked at my  menu program do so now, please.
   1  If you have yet to put a    number into a box then your     Spectrum doesn't believe that   that box exists! Try entering:  
   1  If you don't know which    notes to use then compose by    ear (trial and error).
   1  How about                  
   1  Furthermore, the Spectrum   will not distinguish between    capital and lower case letters. It thinks that 
   1  Experiment with the 
   1  Experiment with 
   1  Each note of the tune must have its own 
   1  E F F# G A
   1  Draw your smile out on     paper first, then translate it  into 
   1  Don't forget to leave room for 
   1  Create your own program thatincludes the 
   1  Coordinates are written in  the order: x-coordinate first,  comma, then y-coordinate. The   Spectrum Manual illustrates the pixel at (191,159) {Dont worry, all will be explained}.  Its    position is found by looking    along the bottom row to find thex-coordinate 191, and marking   its position with a finger of   your left hand, say. Similarly, point to the y-coordinate with aright hand finger on the right  hand side of the diagram.  Now  move your left finger up and    your right finger to the left   until both fingers meet. This ispixel 191,159. To make this moreclear run the program found in  this Learning Element.
   1  Computer people call        anything that appears between   quotation marks (
   1  Colour items can be used in
   1  ANameNotUsedYet 
   1  A menu is a list of optionsone of which the user of the    program can select by entering  the corresponding number. Your  program must, therefore, containan 
   1  24*32=768 character squaresand 8*8=64 pixels per character square.
   1  24 rows, 32 columns.
   1  208,3     
   1  20,20                  120 
   1  127,87;"Circle too big to draw!"
   1  127,87,radius: 
   1  124,84                 110 
   1  120,16     
   1  100              
   1  10,10,PI/2             130 
   1  10,10                  110 
   1  1,16                   110 
   1  0 1  2 3  4 5 6  7 8  9 10 11                                 Adding or subtracting multiples of 12 to or from 
   1  .02,33.9               180 
   1  .02,33.8               170 
   1  .02,33.5               160 
   1  .02,32                 140 
   1  .02,30                 130 
   1  .02,27                 120 
   1  .02,23                 110 
   1  (set     earlier) and 
   1  (don't let it see you        laughing at it, we all have our faults).                                    This also applies tonames for numeric variables:    
   1  "yes"="yes"
   1  "yes"="no"
   1  "What is your name? ":
   1  "The square root of ";number;" is ";answer
   1  "Hello ";n$
   1  "Enter your number";number              
   1  "Do you want to continue? (y/n) ";a$                  110 
   1  "Day? ";Day
   1  "Continue? ";a$       110 
   1  "Bob Dylan"
   1   statement has been executed     the coordinates that your       Spectrum remembers are those    last plotted                    e.g.                  Spectrum                       remembers: after 
   1   means take whatever  you find in the box called 
   1   means is equal to     
   1   less than or equal to       
   1   greenhouses and mustard
   1   greater than.             Modify your program so that it  acts in the  way we've just     described.
   1   greater  than or equal to    
   1   goto the selected option
   1   etc.although input other than n or yhas a different effect in each  case.                           (Note that 
   1   draws a                         semi-cicular                    curve from 110,20               to 110+20,20+30                 (i.e. to 130,50)";
   1   do notlie outside the ranges 0-255 and0-175 respectively.
   1   but make sure that 
   1   Write a program that       repeatedly asks for a number    and then prints a running total and the number of numbers       entered so far.
   1   These conditions are false:        
   1   That was a long winded way of drawing; in the next LearningElement you'll see a much easiermethod. Find out how to unplot apixel i.e. change an ink dot to a paper dot. (Hint: try the     colour items but not 
   1   Remember to start         variables off with zero before  you try to use them!            e.g.  
   1   Remember that you can put a message in your 
   1   Remember that 
   1   Notice that the            x-coordinates must be whole     numbers (integers) and cannot beless than 0 or greater than 255.                                y-coordinates are integers in   the range 0 to 175.
   1    tells your Spectrum to jump to  line 
   1    statements.
   1    Bdum Bdum!
   1    ")?xY1.2;:THEN"
   1     statements and one 
   1     statement.
   1     creates a box called 
   1     Entering
   1      then 
   1      statement. 
   1      70,61          
   1       statement, in order to check forthe numbers 1-4.                Include some instructions to    deal with erroneous input.
   1       130,46          
   1        for the x-axis. Try to place    arrow heads on your axes.
   1         statement.
   1         instructions
   1         e.g.  
   1         0,0    then   
   1          statement, e.g.                
   1          120 
   1           INPUT
   1            statements.
   1              15
   1               80
   1                   Use a sensible 
   1                   "51+2*6"
   1                                Dream up a simple program that  makes use of the BASIC you've   learnt so far.
   1                                 Write a program that gives the  number 632.1 to a variable of   your choice and then prints thatvariable.
   1                                                             I'm desperate for a number!